package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SetmealMapper {

    Integer countByCategoryId(Long id);

    Page<SetmealVO> page(SetmealPageQueryDTO dto);

    @Select("select * from setmeal where id = #{id}")
    Setmeal getSetmealById(Long id);

    @AutoFill(OperationType.UPDATE)
    @Update("update setmeal set status = #{status}, update_time = #{updateTime}, update_user = #{updateUser} where id = #{id}")
    void updateStatus(Setmeal setmeal);

    @AutoFill(OperationType.INSERT)
    Long insert(Setmeal setmeal);

    void deleteByIds(List<Long> ids);

    @AutoFill(OperationType.UPDATE)
    void updateSetmeal(Setmeal setmeal);

    @Select("select * from setmeal where category_id = #{categoryId}")
    List<Setmeal> getSetmealByCategoryId(Long categoryId);

    @Select("select count(id) from setmeal where status = #{status}")
    Integer getStatusCount(Integer status);
}















